﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using System.IO;

namespace WordTemplate1.Formulaire
{
    public partial class AddElementInWork : Form
    {
        public WorkItem Work { get; set; }

        public AddElementInWork()
        {
            InitializeComponent();
        }

        private void btnValider_Click(object sender, EventArgs e)
        {
            if (!Work.IsOpen)
            {
                Work.Open();
            }

            Attachment attachment
                = new Attachment(txtPath.Text, txtNom.Text);

            Work.Attachments.Add(attachment);

            if (Work.IsValid())
            {
                Work.Save();

                Globals.ThisDocument.taskPanel.Actualise();
            }
        }

        private void btnParcourir_Click(object sender, EventArgs e)
        {
            fDialog.InitialDirectory = @"C:\";

            if (fDialog.ShowDialog() == DialogResult.OK)
            {
                string[] NomComplet ;
                NomComplet = fDialog.FileName.Split('\\');
                string donnee = NomComplet[NomComplet.Length-1].Split('.')[0];

                txtPath.Text = fDialog.FileName.ToString();
                txtNom.Text = donnee;
            }
        }

        private void btnAnnuler_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
